#!/bin/bash

echo "===================================="
echo "   MySQL数据库初始化脚本"
echo "===================================="
echo

read -p "请输入MySQL用户名(默认root): " MYSQL_USER
MYSQL_USER=${MYSQL_USER:-root}

read -s -p "请输入MySQL密码: " MYSQL_PASSWORD
echo

echo
echo "正在执行数据库初始化脚本..."
mysql -u $MYSQL_USER -p$MYSQL_PASSWORD < ../DB模块/init_database.sql

if [ $? -eq 0 ]; then
    echo
    echo "✅ 数据库初始化成功！"
    echo "📊 数据库: test22"
    echo "📋 表: student"
    echo "🎉 完成！"
else
    echo
    echo "❌ 数据库初始化失败！"
    echo "💡 请检查MySQL服务是否启动，用户名密码是否正确"
fi